{extend name='admin@main'}

{block name="content"}




<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off" id="Newform" onsubmit="return false;">

		<blockquote class="layui-elem-quote">
		
			<span class="layui-badge layui-bg-green">在某些浏览器下，页面可能加载不完整，如果出现这种情况，请按F5重新加载页面!</span>
		  
		</blockquote>

        <div class="layui-form-item nowrap ">
            <label class="layui-form-label ">姓名</label>
            <div class="layui-input-inline margin-right-0" style="width:250px">
                {if session('admin_user')['username']=='admin' && request()->action() =='add_holiday' }

				
				
                    <select class="layui-select" lay-verify="required"  required name="name" lay-search id="name" lay-filter="name">
                        <option value="">请选择</option>
                        {foreach $list as $k=>$v}
                        {eq name='$vo.name' value='$v["nickname"]'}
                        <option selected value="{$v["nickname"]}" readonly>{$v["nickname"]}</option>
                        {else}
                        <option value="{$v["nickname"]}">{$v["nickname"]}</option>
                        {/eq}
                        {/foreach}
                    </select>
				{else}
				
					{if isset($vo) and isset($vo.name)}
					<input disabled value='{$vo.name|default=session('admin_user')['nickname']}' class="layui-input layui-bg-gray" id="name">
					{else}
					<input name="name" value='{$vo.name|default=session('admin_user')['nickname']}' required class="layui-input layui-bg-gray" id="name">
					{/if}
				{/if}
				
            </div>

            <label class="layui-form-label ">工龄</label>
            <div class="layui-input-inline margin-right-0" style="width:150px">
				<input name="gongling" class="layui-input" placeholder="工龄" value="{$vo.gongling|default=''}">
            </div>


        </div>




        <div class="layui-form-item">
            <label class="layui-form-label ">类型</label>
            <div class="layui-input-block">
                        {foreach $leixing as $k=>$v}
                        {if $k !=''}
                            {eq name='$vo.leixing' value='$k.""'}
<input type="radio" lay-filter="leixing" name="leixing" id="leixing" required title="{$v}" checked value="{$k}" {if isset($vo) and isset($vo.leixing)} disabled {/if} >
                            {else}
<input type="radio" lay-filter="leixing" name="leixing" id="leixing" required title="{$v}" value="{$k}"  {if isset($vo) and isset($vo.leixing)} disabled {/if}>
                            {/eq}
                        {/if}
                        {/foreach}
            </div>
        </div>


        <div class="layui-form-item nowrap ">
            <label class="layui-form-label ">可休天数(只读）</label>
            <div class="layui-input-inline margin-right-0" style="width:150px">
				<input name="yingxiu" id="yingxiu" required class="layui-input" placeholder="可休天数" value="{$vo.yingxiu|default='0.0'}" readonly>
            </div>

            <label class="layui-form-label ">已休天数(只读）</label>
            <div class="layui-input-inline margin-right-0" style="width:150px">
				<input name="yixiu" id="yixiu" required class="layui-input" placeholder="已休天数" value="{$vo.yixiu|default='0.0'}" readonly>
            </div>

            <label class="layui-form-label ">未休天数(只读）</label>
            <div class="layui-input-inline margin-right-0" style="width:150px">
				<input name="weixiu" id="weixiu" class="layui-input" placeholder="未休天数" required  value="{$vo.weixiu|default='0.0'}" readonly>
            </div>
        </div>

<!--
        <div class="layui-form-item">
            <label class="layui-form-label ">单位人事 </label>
            <div class="layui-input-block">
                <div id="lists" class="xm-select-demo"></div>
            </div>
        </div>
-->




        <div class="layui-form-item nowrap ">
            <label class="layui-form-label ">起始时间</label>
            <div class="layui-input-inline margin-right-0" style="width:150px">
				<input name="startdate" id="startdate" required class="layui-input" placeholder="起始时间" value="{$vo.startdate|default=''}" {if isset($vo) and isset($vo.startdate)} disabled {/if} >
            </div>

            <label class="layui-form-label ">结束时间</label>
            <div class="layui-input-inline margin-right-0" style="width:150px">
                <input name="enddate" id="enddate" required class="layui-input" placeholder="结束时间" value="{$vo.enddate|default=''}"
        {if isset($vo) and isset($vo.enddate)} disabled {/if} >
            </div>

            <label class="layui-form-label ">请假天数</label>
            <div class="layui-input-inline margin-right-0" style="width:350px">
                <input name="days" class="layui-input" placeholder="请假天数，只能填1,2,1.5,2.5等" id="days" required  pattern="^[0-9]+(.[0|5]{1})?$" value="{$vo.days|default=''}" {if isset($vo) and isset($vo.days)} disabled {/if} >
            </div>

			<div id="addnew" style="display:none;">
            <a class="layui-btn layui-btn-sm layui-btn-danger" onclick="open_new();" >新增</a>
            <a class="layui-btn layui-btn-sm layui-btn-normal" onclick="culate(this)">计算</a>
			</div>
            <!-- <a class="layui-btn layui-btn-sm layui-btn-danger" onclick="addCustomList('customList')">新增</a> -->
			<!-- <button data-modal="/person/holiday/lists.html" data-title="选择假期" class="layui-btn layui-btn-sm layui-btn-danger">选择假期</button> -->

        </div>


        <div class="layui-form-item">
            <label class="layui-form-label ">值班/加班</label>
            <div class="layui-input-block">
                <table id="customList" class="layui-table">
                    <thead>
                        <tr>
                            <th width="9%">ID</th>
                            <th>姓名</th>
                            <th>值班/加班日期</th>
                            <th>类型</th>
                            <th>换休天数</th>
                            <th>已休天数</th>
                            <th>准备休天数</th>
                            <th width="14%">操作</th>
                        </tr>
                    </thead>
					<tbody>
					{foreach $jiaqi_flow as $key=>$vo}
						<tr>
							<td>{$vo.j_id}</td>
							<td>{$vo.j_name}</td>
							<td>{$vo.j_otdate}</td>
							<td>{$vo.j_datetype}</td>
							<td>{$vo.j_buxiunum}</td>
							<td>{$vo.j_yixiunum}</td>
							<td>{$vo.j_days}</td>
							<td></td>
						</tr>
					{/foreach}
					</tbody>
                </table>
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label ">单位人事</label>
            <div class="layui-input-block">
                <div id="shouwenwenyuan" class="xm-select-demo"></div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label ">科室负责人</label>
            <div class="layui-input-block">
                <div id="keshifuzeren" class="xm-select-demo"></div>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label ">分管领导</label>
            <div class="layui-input-block">
                <div id="fenguanlingdao" class="xm-select-demo"></div>
            </div>
        </div>
        


        <div class="layui-form-item">
            <label class="layui-form-label ">休假原因</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" name="remark" id="remark" placeholder="休假原因">{$remark|default=""}</textarea>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label ">文件附件</label>
            <div class="layui-input-block">
				<input name="files" id="files" class="layui-input" value="{$attaches|default=''}" readonly>
                <button type="button" class="layui-btn layui-btn-sm" id="file_attach"><i class="layui-icon"></i>上传文件</button>
				{if $attaches !=''}&nbsp;&nbsp;<a class="layui-btn layui-btn-sm " href="{$attaches}" target="new">查看</a>{/if}
            </div>
        </div>

		{if request()->action() =='edit_holiday' || request()->action() =='viewdoc' }
        <div class="layui-form-item">
            <label class="layui-form-label ">批示情况</label>
            <div class="layui-input-block">
                    <div class="layui-textarea padding-bottom-10" style="min-height:auto">

                            <table class="layui-table">
                              <thead>
                                <tr>
                                <th>批示人</th>
                                <th>批示时间</th>
                                <th>批示类型</th>
                                <th width="164px">批示内容</th>
                              </tr></thead>
                              {foreach $list_flow as $key=>$vo}
                              <tr id="upload-{$vo.id}">
                              <td>{$vo.username}</td>
                              <td>{$vo.addtime|format_datetime='Y-m-d H:i'}</td>
                              
                              <td>                
                              {eq name='vo.types' value='nigao'}<span class="layui-bg-red">提交申请</span>{/eq}
                              
                              {eq name='vo.types' value='shouwenwenyuan'}<span class="layui-bg-green">人事审核</span>{/eq}

                              {eq name='vo.types' value='keshifuzeren'}<span class="layui-bg-orange">科室/项目负责人审核</span>{/eq}

                              {eq name='vo.types' value='bangongshizhuren'}<span class="layui-bg-blue">办公室主任</span>{/eq}
                              {eq name='vo.types' value='fenguanlingdao'}<span class="layui-bg-black">分管领导</span>{/eq}
                              {eq name='vo.types' value='zhuyaolingdao'}<span class="layui-bg-gray">主要领导</span>{/eq}
                              </td>
                              
                              <td> {$vo.info}</td>  <tr>
                              {/foreach}
                            </table>

                    </div>
            </div>
        </div>
		{/if}
		




        {if request()->action() =='edit_holiday' && $rs_flow >0 && $my_flow_count ==0 }
        <div class="layui-form-item">
            <label class="layui-form-label">填写意见</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" name="info" id="info" placeholder="请填写批示意见">{$info|default=""}</textarea>
            </div>
            
        </div>
        {/if}



        <div class="layui-form-item text-center">
            <input type="hidden" name="types" id="types" value="{$vo.leixing}">
            {notempty name='id'}<input type="hidden" name="id" id="id" value="{$id}">{/notempty}

            {if request()->action() =='edit_holiday' && $rs_flow >0 && $my_flow_count ==0 }
            <button class="layui-btn" type='button' id="saveinfo">保存批示意见</button>
            {/if}

            {if request()->action() =='add_holiday' }
            <button class="layui-btn" type="submit">保存</button>
            {/if}
            <button class="layui-btn layui-btn-danger" onclick="hsitoryBack()" type="button">关闭</button>
            
        </div>

    </div>
</form>
{/block}

{block name='script'}

<script src="__ROOT__/static/plugs/laydate/laydate.js"></script>
<script src="__ROOT__/static/plugs/select/xm-Select.js"></script>
<script>

	$(document).ready(function(){
		$("#addnew").hide();
		//$("#remark").attr('value','{$vo.remark}');
		//alert({$vo.remark});
	});

	function open_new()
	{

		//console.log($('#name').val());
		var leixing =  $('input:radio[name=leixing]:checked').val();
		var datetype;
		var name =$('#name').val();
		if(leixing =='2'){
			datetype ='zhiban';
		}else{
			datetype='jiaban';
		}
		x_admin_show('新增','{:url('list')}?datetype='+datetype+'&name='+name ,750 ,450);
	}






//pend('<label class="form-label col-xs-2 col-sm-2"><span class="c-red" id="FK"'+i+'"" name="FK"'+i+'"">'+item[i].LoanName+'</span></label><div class="formControls col-xs-4 col-sm-4"><input data-pid="'+item[i].PID+'" data-FewDays="'+item[i].FewDays+'" data-index="'+i+'" type="text" class="input-text" name="txt_Money" id="txt_Money'+i+'" style="width:100px;" value="'+($('#RealMoney').val()*(item[i].Proportion/100)).toFixed(2)+'"/></div>')

    //window.form.render();
	
	
	
	function culate1(obj)
	{
			$('#customList ').find("input[name='j_days[]']").each(function(index , element){
			//$('#customList').find("tr").each(function(index , element){
				//console.log(element)
				
				//var tdArr = $(this).children();
				
				//console.log(e)
				var changeIndex =$(this).find("input[name='j_days[]']").val();
				var j_buxiunum =$(this).find("input[name='j_buxiunum[]']").val();
				var j_yixiunum =$(this).find("input[name='j_yixiunum[]']").val();
				
				
				var j_kexiunum =j_buxiunum-j_yixiunum;
				
				console.log(j_buxiunum + j_yixiunum + j_kexiunum)
				
				if(isNaN($(this).val()) || changeIndex==null || changeIndex ==undefined || changeIndex=="")
				{
					layer.msg("请输入正确的天数！", { icon: 2, time: 2000 });
					return false;
					//$(this).val(($('#RealMoney').val()*(item[changeIndex].Proportion)/100).toFixed(2));
				}
				if( Math.ceil( changeIndex % 0.5) !=0 || changeIndex > j_kexiunum )
				{
					layer.msg("请核实数据是否有误！", { icon: 2, time: 2000 });
					$(this).find("input[name='j_days[]']").attr("value","0.0");
					$("#days").attr("value","");
					return false;
				}
				alert(changeIndex);
				//SumMoney();
				culate(this);
			});
		return false;
	}
	
	$("body").click(function(event){
		var $this = $(event.target);
		//SumMoney();
	});

	function culate(obj)
	{	
		var _money=0;
		$("#remark").attr('value' , '');
	
		var trList = $("#customList tbody").children("tr")  
		
		for (var i=0;i<trList.length;i++) {  
			var tdArr = trList.eq(i).find("td");  
			var remark = tdArr.eq(2).find("input").val()+tdArr.eq(3).find("input").val();
			var data1 = tdArr.eq(4).find("input").val();//收入类别  
			var data2 = tdArr.eq(5).find("input").val();//收入金额  
			var data3 = tdArr.eq(6).find("input").val();//    备注  
			var changeIndex =$(this).find('tr').find("input[name='j_days[]']").val();
			
			//alert(data1);  

			if(isNaN( data3 ) || data3==null || data3 ==undefined || data3=="" )
			{
				layer.msg("请输入正确的天数！", { icon: 2, time: 2000 });
				return false;
			}
			
			data4= data1-data2;
			if( Math.ceil( data3 % 0.5) !=0 || data3 > data4 || data3 <0)
			{
				layer.msg("请核实数据是否有误！", { icon: 2, time: 2000 });
				tdArr.eq(6).find("input").attr("value","");
				$("#days").attr("value","");
				return false;
			}
			
			_money+=Number( data3 );
			
			$("#days").attr('value' , _money);
			$("#remark").val($("#remark").val()+ ' , ' +remark);
		} 
		var days =$("#days").val();
		var weixiu =$("#weixiu").val();
		
		if(parseFloat( days ) > parseFloat( weixiu ) ){
			layer.msg('休假天数不能大于未休天数,最多能休'+parseFloat( $("#weixiu").val() )+"天");
			$('#days').attr('value' , '0.0')
			return false;
		}
		
		//SumMoney();
		return true;
	}
	
	/*合计*/
	function SumMoney()
	{
	   //定义一个变量并附初始值。
		var _money=0;
		   //循环遍历文本框input
		$('#customList').find("input[name='j_days[]']").each(function(){
		   //累加求和
			_money+=Number($(this).val());
		});
		//var SumMoney=$("#RealMoney").val();
		//判断输入的合计金额和成交总价是否相等
		if( Math.ceil(_money % 0.5) !=0  )
		{
			layer.msg("请核实数据是否有误!!！", { icon: 2, time: 2000 });
			$("#days").attr('value' , '');
			$(this).find("input[name='j_days[]']").attr("value","0.0");
			return false;
		}else{
			$("#days").attr('value' , _money);
			return true
		}
	}

    //删除
    function delCustomList(_this){
        layui.use(['form','laydate'], function() {
            layer.confirm('确定要删除么？', {
                btn: ['确定', '取消'] //按钮
            }, function() {
                $(_this).parent().parent().remove();
				//SumMoney();
				culate(this);
                layer.msg('删除成功', {
                    icon: 1
                });
            }, function() {
                layer.msg('取消删除', {
                    time: 2000 //20s后自动关闭
                });
            });
        });
    }
	
    //日期开始
    var start = {
        elem: '#startdate',
        //max: laydate.now(),
        istoday: true,
        change: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas; //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#enddate',
        //max: laydate.now(),
        change: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };

    laydate.render(start);
    laydate.render(end);
    //日期结束


    function hsitoryBack(){
        $.msg.confirm('确定要关闭吗？', function (index) {
            history.back(), $.msg.close(index);
        });
    };

    /*
    function hsitoryBack(){
        $.msg.confirm('确定要关闭吗？', function (index) {
            history.back(), $.msg.close(index);
        });
    };
    require(['angular','plugs/select/xm-Select'], function () {
        //window.createEditor('[name="content"]', {height: 250});
        var app = angular.module("Newform", []).run(callback);
        
        function callback($rootScope) {
            // 返回列表
            $rootScope.hsitoryBack = function () {
                $.msg.confirm('确定要取消编辑吗？', function (index) {
                    history.back(), $.msg.close(index);
                });
            };
        }
    });
    */

	layui.use(['form', 'layedit', 'laydate','upload'], function(){
		  var form = layui.form
		  ,layer = layui.layer
		  ,layedit = layui.layedit
		  ,laydate = layui.laydate
		,upload = layui.upload;
		var $ = layui.jquery;
		
		upload.render({ //允许上传的文件后缀
			elem: '#file_attach'
			,url: '{:url("upload")}'
			,accept: 'file' //普通文件
			,exts: 'pdf|jpg|gif|doc|docx|zip|rar|7z' //只允许上传的文件
			,done: function(res, index, upload) {
			console.log(res)
				$("#files").attr("value", res.url);
			}
		});


	var leixing_1;
	form.on('radio(leixing)', function(data){

		//$("#days").val('');
		$("#days").attr("value" , '0.0');
		window.form.render();
		//alert(data.elem);
		//console.log(data.elem);
		//alert(data.value);//判断单选框的选中值

		$("#types").attr("value" , data.value);

		leixing_1 =data.value;
		var objS = document.getElementById("name");
		var users=$("#name").val();
		if(users ==''){
			layer.msg('请选择休假人员!');
			return ;
		}

		if( leixing_1 ==1){
			$("#remark").val('');
			leixing ='nianjia';
			var yingxiu ='yxnianjia';
			$("#days").attr("value" , '0.0');
			$("#days").removeAttr("readonly");
			$("#days").removeClass("layui-bg-gray");
			$("#addnew").hide();
			
			
			var date3;
			$.post("{:url('getyears')}",{name:users},function(result){
				console.log(result)
				$("#yingxiu").attr("value" , result.nianjia);
				$("#yixiu").attr("value" , result.yixiunianjia);
				var date1= result.nianjia;
				var date2= result.yixiunianjia;
				date3= date1-date2;
				$("#weixiu").attr("value" , date3);
			});	
			//console.log(date3);
			if(parseFloat( $("#days").val() ) > parseFloat( $("#weixiu").val() ) ){

				layer.msg('休假天数不能大于未休天数,最多能休'+parseFloat( $("#weixiu").val() )+"天");
				$('#weixiu').css('border','1px solid red');
				$('#weixiu').css("color", "blue");
				//$('#days').val('').focus();
			}
			$('#customList #list').remove();
			window.form.render();
		}else if(leixing_1 ==2){
			//alert(leixing_1)
			$("#remark").val('');
			$("#days").attr("value" , '0.0');
			$("#days").attr("readonly","true");
			$("#days").addClass("layui-bg-gray");
			$("#addnew").show();
			
			//$("input[name='days[]']").addclass("layui-bg-gray");
			
			leixing ='zhiban';
			var yingxiu ='zhibanbuxiu';
			$.post("{:url('getdate')}",{name:users,leixing:leixing,yingxiu:yingxiu},function(result){
				$("#yingxiu").attr("value" , result.zhiban);
				//$("#yingxiu").attr("value" , result.buxiu);
				$("#yixiu").attr("value" , result.zhibanbuxiu);
				//$("#yixiu").attr("value" , result.yixiubuxiu);
				var date1= result.zhiban;
				//var date1= result.buxiu;
				var date2= result.zhibanbuxiu;
				//var date2= result.yixiubuxiu;
				var date3= date1-date2;
				$("#weixiu").attr("value" , date3);
			});
			
			if(parseFloat( $("#days").val() ) > parseFloat( $("#weixiu").val() ) ){

				layer.msg('休假天数不能大于未休天数,最多能休'+parseFloat( $("#weixiu").val() )+"天");
				$('#weixiu').css('border','1px solid red');
				$('#weixiu').css("color", "blue");
				//$('#days').val('').focus();
			}

			$('#customList #list').remove();
			window.form.render();
		}else if(leixing_1 ==3){
			$("#remark").val('');
			$("#days").attr("value" , '0.0');
			$("#days").attr("readonly","true");
			$("#days").addClass("layui-bg-gray");
			
			$("#addnew").show();
			
			leixing ='jiaban';
			var yingxiu ='jiabanbuxiu';
			$.post("{:url('getdate')}",{name:users,leixing:leixing,yingxiu:yingxiu},function(result){
				$("#yingxiu").attr("value" , result.jiaban);
				//$("#yingxiu").attr("value" , result.buxiu);
				$("#yixiu").attr("value" , result.jiabanbuxiu);
				//$("#yixiu").attr("value" , result.yixiubuxiu);
				var date1= result.jiaban;
				//var date1= result.buxiu;
				var date2= result.jiabanbuxiu;
				//var date2= result.yixiubuxiu;
				var date3= date1-date2;
				$("#weixiu").attr("value" , date3);
			});
			if(parseFloat( $("#days").val() ) > parseFloat( $("#weixiu").val() ) ){

				layer.msg('休假天数不能大于未休天数,最多能休'+parseFloat( $("#weixiu").val() )+"天");
				$('#weixiu').css('border','1px solid red');
				$('#weixiu').css("color", "blue");
				//$('#days').val('').focus();
			}
			$("#days").attr("value" , '0.0');
			$('#customList #list').remove();
			window.form.render();
		}else{
			//$("#remark").attr('value' , ' ');
			$("#days").attr("value" , '0.0');
			$("#remark").val('');
			leixing ='others';
			$("#yingxiu").attr("value" , '0.0');
			$("#yixiu").attr("value" , '0.0');
			$("#weixiu").attr("value" , '0.0');
			$("#days").removeAttr("readonly");

			$("#addnew").hide();
			$("#days").removeClass("layui-bg-gray");
			$("#days").attr("value" , '0.0');
			$('#customList #list').remove();
		}
		window.form.render();
	});

	$("#days").on("input",function(e){
	//获取input输入的值
	//console.log(e.delegateTarget.value);
	var days =$("#days").val();
	var weixiu =$("#weixiu").val();


	if(leixing_1 <=3 ){
		if(parseFloat(days) > parseFloat(weixiu) ){
			layer.msg('休假天数不能大于未休天数,最多能休'+parseFloat(weixiu)+"天");
			$('#weixiu').css('border','1px solid red');
			$('#weixiu').css("color", "blue");
			$('#days').val('').focus();
		}
	}

	});

	var keshifuzeren = xmSelect.render({
		el: '#keshifuzeren', 
		name: 'keshifuzeren',
		toolbar: {
			//show: true,
			//list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},

		theme: {
			color: '#0081ff',
		},          
		paging: true,
		pageSize: 10,
		radio: true,
		filterable: true,
		data: [
			{$str}
		]
	})


        
	var fenguanlingdao = xmSelect.render({
		el: '#fenguanlingdao', 
		filterable: true,
		name: 'fenguanlingdao',
		paging: true,
		pageSize: 10,
		toolbar: {
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		theme: {
			color: '#8dc63f',
		},
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 3,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},
		data: [
			{$str}
		]
	})
        
	var shouwenwenyuan = xmSelect.render({
		el: '#shouwenwenyuan', 
		name: 'shouwenwenyuan',
		toolbar: {
			show: true,
			list: [ 'ALL', 'CLEAR', 'REVERSE' ]
		},
		paging: true,
		pageSize: 10,
		filterable: true,
		theme: {
			color: '#e54d42',
		},
		model: {
			label: {
				type: 'block',
				block: {
					//最大显示数量, 0:不限制
					showCount: 3,
					//是否显示删除图标
					showIcon: true,
				}
			}
		},

		data: [
			{$str}
		]
	})

	{if isset($vo) }
	keshifuzeren.setValue([ {$keshifuzeren} ])
	
	fenguanlingdao.setValue([ {$fenguanlingdao} ])
	
	shouwenwenyuan.setValue([ {$shouwenwenyuan} ])
	
	{/if}



    });


    layui.use(['layer','form' ,'jquery'], function() {
        var layer = layui.layer, $ = layui.jquery ,form = layui.form;
        form.render();
    });
    

    $('#saveinfo').click(function(){
        var info = $("#info").val();
        var docid =$("#id").val();

        
        if(info == ''){
            layer.msg('请填写批示意见!',{icon: 5});//失败的表情
            return ;        
        }
        
        //alert(info);
        
        var url = "/person/holiday/saveinfo.html";
        $.ajax({
            url:url,
            type:'post',
            data:'info='+info+'&docid='+docid,
            beforeSend:function () {
                
                this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
            },
            success:function(data){
                if (data['code'] ==0) {
                    layer.msg(data.msg,{icon: 5});//失败的表情
                    return false;                    
                }
                if(data.status == 'error'){
                    layer.msg(data.msg,{icon: 5});//失败的表情
                    return;
                }else if(data.status == 'success'){
                    //layer.msg(data.msg,{icon: 6});
                    layer.msg(data.msg, {
                        icon: 6,//成功的表情
                        time: 2000 //1秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        //location.reload();
                        window.location.href="/admin.html#/person/holiday/uncheckholiday.html?spm=m-77-88-92";
                    });
                }
            },
            complete: function () {
                layer.close(this.layerIndex);
            },
        });
        return false;//阻止表单跳转
    });

	/*弹出层*/
	/*
		参数解释：
		title   标题
		url     请求的url
		id      需要操作的数据id
		w       弹出层宽度（缺省调默认值）
		h       弹出层高度（缺省调默认值）
	*/
	function x_admin_show(title,url,w,h){
		if (title == null || title == '') {
			title=false;
		};
		if (url == null || url == '') {
			url="404.html";
		};
		if (w == null || w == '') {
			w=($(window).width()*0.9);
		};
		if (h == null || h == '') {
			h=($(window).height() - 50);
		};
		layer.open({
			type: 2,
			area: [w+'px', h +'px'],
			fix: false, //不固定
			maxmin: true,
			shadeClose: true,
			shade:0.4,
			title: title,
			content: url
		});
	}

	/*关闭弹出框口*/
	function x_admin_close(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	} 

</script>
{/block}